'''
Created on Dec 22, 2013

@author: Justin
'''

from basecommand import BaseCommand as bc
from src.world import World
import src.constants as const

# Classes in this module should be in alphabetical order
### A ###
### B ###
### C ###
### D ###
### E ###
### F ###
### G ###
### H ###
### I ###
### J ###
### K ###
### L ###
class Look(bc):
  """look"""
  def action(self):
    
    if self.room:
      msg = [self.room.name + " {}".format(self.room.coords),
             self.interface_border,
             self.room.description,
             "Exits: {}".format(", ".join(self.room.exits.keys()))]
      self.sendMsg(msg, "player")
    else:
      self.sendMsg("You're nowhere...", "player")

### M ###
class Move(bc):
  """n s e w ne nw se sw u d"""
  def action(self):

    direction = const.DIRECTION_SHORTCUT[self.cmd_entered]
    new_room_coords = self.room.exits.get(direction)
    new_room = World.rooms.get(str(new_room_coords))
    if new_room:
      self.player.move(new_room.coords)
      self.player.hear("You walk {0}".format(direction))
      Look().executeCmd(self.player)
    else:
      self.sendMsg("There's no exit in that direction.", "player")
      self.sendMsg("{} fumbles around to the {}, going nowhere...".format(
          self.player.name, direction), "room")

### N ###
### O ###
### P ###

### Q ###
class Quit(bc):
  """quit logout"""
  def action(self):
    
    self.player.save()
    self.player.logout()

### R ###

### S ###
class Say(bc):
  "say"
  def action(self):
    
    player_msg = "You say, {}".format(" ".join(self.args))
    room_msg = "{} says, '{}'".format(self.player.name,
                                    " ".join(self.args))
    self.sendMsg(player_msg, "player")
    self.sendMsg(room_msg, "room")
          

class ShowStats(bc):
  """score stats"""
  def action(self):

    self.isinterface = True
    self.sendMsg("HP: {}".format(self.player.hp["max"]), "player")

### T ###
### U ###
### V ###
### W ###
### X ###
### Y ###
### Z ###
